package com.zk.stock.controller;

import cn.hutool.http.server.HttpServerResponse;
import com.zk.stock.pojo.domain.*;
import com.zk.stock.pojo.vo.StockInfoConfig;
import com.zk.stock.service.StockService;
import com.zk.stock.vo.resp.PageResult;
import com.zk.stock.vo.resp.R;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * @author 曹自康的Laptop
 * @version 1.0
 * @Date 2024-06-3018:03 股票控制器
 */
@Api(value = "/api/quot", tags = {""})
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/quot")
public class StockController {
    private final StockService stockService;

    /**
     * 获取国内大盘最新的数据
     * @return
     */
    @ApiOperation(value = "获取国内大盘最新的数据", notes = "获取国内大盘最新的数据", httpMethod = "GET")
    @GetMapping("/index/all")
    public R<List<InnerMarketDomain>> getInnerMarket(){

        return stockService.getInnerMarket();
    }
    @ApiOperation(value = "", notes = "", httpMethod = "GET")
    @GetMapping("/sector/all")
    public R<List<StockBlockDomain>> getStockBlockAll(){
        return stockService.getStockBlockAll();
    }

    /**
     * 分页查询最新的股票交易数据
     * @param page
     * @param pageSize
     * @return
     */
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "page", value = ""),
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "pageSize", value = "")
    })
    @ApiOperation(value = "分页查询最新的股票交易数据", notes = "分页查询最新的股票交易数据", httpMethod = "GET")
    @GetMapping("/stock/all")
    public R<PageResult<StockUpdownDomain>> getStockInfoByPage(@RequestParam(required = false,defaultValue = "1") Integer page,
                                                               @RequestParam(required = false,defaultValue = "20") Integer pageSize){
      return   stockService.getStockInfoByPage(page,pageSize);
    }

    @ApiOperation(value = "", notes = "", httpMethod = "GET")
    @GetMapping("/stock/increase")
    public R<List<StockUpdownDomain>> stockUpdownDomainList(){
       List<StockUpdownDomain> stockLists = stockService.stockUpdownDomainList();
        return R.ok(stockLists);
    }

    /**
     * 统计最新股票交易日内每分钟的的涨跌停的股票的数量
     * @return
     */
    @ApiOperation(value = "统计最新股票交易日内每分钟的的涨跌停的股票的数量", notes = "统计最新股票交易日内每分钟的的涨跌停的股票的数量", httpMethod = "GET")
    @GetMapping("/stock/updown/count")
    public R<Map<String,List>> getStockUpDownCount(){
        return stockService.getStockUpDownCount();
    }

    /**
     * 导出指定页码的最新股票信息
     * @param page
     * @param pageSize
     * @param response
     */

    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "page", value = ""),
            @ApiImplicitParam(paramType = "query", dataType = "int", name = "pageSize", value = "")
    })
    @ApiOperation(value = "导出指定页码的最新股票信息", notes = "导出指定页码的最新股票信息", httpMethod = "GET")
    @GetMapping("/stock/export")
    public void exportStockUpDownInfo(@RequestParam(required = false,defaultValue = "1") Integer page,
                                      @RequestParam(required = false,defaultValue = "20") Integer pageSize,
                                      HttpServletResponse response){
        stockService.exportStockUpDownInfo(page,pageSize,response);

    }

    /**
     * 统计大盘T日和T-1日的每分钟的成交量的统计
     * @return
     */
    @ApiOperation(value = "统计大盘T日和T-1日的每分钟的成交量的统计", notes = "统计大盘T日和T-1日的每分钟的成交量的统计", httpMethod = "GET")
    @GetMapping("/stock/tradeAmt")
    public R<Map<String,List>> getStockTradeAmt(){
        return stockService.getStockTradeAmt();

    }
    @ApiOperation(value = "", notes = "", httpMethod = "GET")
    @GetMapping("/stock/updown")
    public R<Map> getIncreaseRangeInfo(){
        return stockService.getIncreaseRangeInfo();
    }

    /**
     * 个股分时K线行情接口说明
     * @return
     */

    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", dataType = "string", name = "code", value = "", required = true)
    })
    @ApiOperation(value = "个股分时K线行情接口说明", notes = "个股分时K线行情接口说明", httpMethod = "GET")
    @GetMapping("/stock/screen/time-sharing")
    public R<List<Stock4MinuteDomain>> getScreenTimeSharing(@RequestParam("code")String code){

        return stockService.getScreenTimeSharing(code);
    }
    @GetMapping("/stock/screen/dkline")
    public R<List<Stock4EvrDayDomain>> getScreenDkline(@RequestParam("code")String code){
        return stockService.getScreenDkline(code);
    }




}
